import request from '@/utils/request'

/************** 用户 *************/

/**   接口名称目录        功能
      1.listUser         列表接口  查询
      2.saveUser         新增
      3.modifyUser       编辑  
      4.getUserDetail    获取编辑该条详情
      5.removeUser       删除
      6.stopAUser        停用
      7.startAUser       启用
**/
/************** 部门 *************/
/**   接口名称目录        功能
      8.listDepart       初始化部门树
      9.saveDepart       新增
      10.getParentName   获取编辑该条详情    
      11.modifyDepart    编辑 
      12.removeDepeart   删除
      
**/
//1.
export const listUser = (search) => 
    request({
        url: '/sys/user/get_user_list',
        method: 'get',
        params: {
            pageSize: search.limit,
            keyWord:search.name,
            pageNo:search.currentPage,
            useable:search.useable
        }        
    })
//2.
export const saveUser = (form) =>
	request({
		url: '/sys/user/create_user',
        method: 'post',
        data:JSON.stringify(form)
	}) 
//3.
export const modifyUser = (form) =>
	request({
		url: '/sys/user/modify_user',
        method: 'post',
        data:JSON.stringify(form)
	}) 
//4.
export  const  getUserDetail = (code) =>
	request({
		url:'/sys/user/get_user',
		method:'get',
		params:{
			code
		}
	})
//5.
export  const  removeUser = (code) =>
	request({
		url:'/sys/user/delete_user',
		method:'get',
		params:{
			code
		}
	})
//6.
export  const  stopAUser = (code) =>
	request({
		url:'/sys/user/lock_user',
		method:'get',
		params:{
			code
		}
	})
//7.
export  const  startAUser = (code) =>
    request({
    	url:'/sys/user/unlock_user',
		method:'get',
		params:{
			code
		}
    })



/************** 部门 *************/
//8. 初始化部门树  
export const listDepart = (search) => 
    request({
        url: '/op/office/get_office_list',
        method: 'get',
        params: {
            pageSize: search.limit,
            pageNo:search.currentPage
        }        
    })

//9.新增部门
export const  saveDepart = (form) =>
	request({
		url:'/op/office/create_office',
		method:'post',
		data:JSON.stringify(form)
	})

//10.获取上级部门名称
export  const  getParentName = (code) =>
	request({
		url:'/op/office/get_office',
		method:'get',
		params:{
			code
		}
	})

//11.修改部门
export  const  modifyDepart = (form) =>
	request({
		url:'/op/office/modify_office',
		method:'post',
		data:JSON.stringify(form)
	})

//12.删除
export  const  removeDepeart = (code) =>
	request({
		url:'/op/office/delete_office',
		method:'get',
		params:{
			code
		}
	})